package com.training.java.core.pre15;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class CarMutableDemo {

	public static void main(String[] args) {

		CarMutable car1 = new CarMutable();

		car1.setMake("Ford");
		car1.setModel("Focus");
		car1.setYear(2013);

		CarMutable car2 = new CarMutable();

		car2.setMake("Honda");
		car2.setModel("Accord");
		car2.setYear(2014);

		CarMutable car3 = new CarMutable();

		car3.setMake("Benz");
		car3.setModel("E250");
		car3.setYear(2015);

		List cars = new ArrayList();

		cars.add(car1);
		cars.add(car2);
		cars.add(car3);

		// read from list

		Iterator carsIterator = cars.iterator();

		while (carsIterator.hasNext()) {

			CarMutable aCarMutable = (CarMutable) carsIterator.next();

			System.out.println("Start printing CarMutable details *******");

			System.out.println("Make = " + aCarMutable.getMake());
			System.out.println("Model = " + aCarMutable.getModel());
			System.out.println("Year = " + aCarMutable.getYear());

			System.out.println("End printing CarMutable details *******");

		}

	}

}
